var md_user=(function($,md_list){
    var app={
        listvalid:{
            rules: {
                userid: {
                    required: true,
                },
                album: {
                    required: true,
                },
                title: {
                    required: true,
                },
                description: {
                    required: true,
                }
            },
            messages: {
                userid: {
                    required: "用户名不能为空"
                },
                album: {
                    required: "专辑不能为空"
                },
                title: {
                    required: "标题不能为空"
                },
                description: {
                    required: "描述不能为空"
                }
            }
        },
        initEvent:function(){
            var _this=this;

            $("#userid").on("change",function(){
                var userid=$(this).val();
                md_common.postAjax("/admin/album/loadInfoByUserId",{'userid':userid},function(result){
                    var html="";
                    if(result.list){
                        for(var i=0;i<result.list.length;i++){
                            html+="<option value='"+result.list[i]['id']+"'>"+result.list[i]['caption']+"</option>";
                        }
                    }
                    $("#c_album").html(html);
                });
            });

            $(".update_item").on("click",function(){
                var albumid=$(this).attr("data-albumid");
                var album=$(this).attr("data-album");
                var userid=$(this).attr("data-userid");
                md_common.postAjax("/admin/album/loadInfoByUserId",{'userid':userid},function(result){
                    var html="";
                    if(result.list){
                        for(var i=0;i<result.list.length;i++){
                            if(result.list[i]['id']==albumid){
                                 html+="<option  selected value='"+result.list[i]['id']+"'>"+result.list[i]['caption']+"</option>";
                            }
                            else{
                                 html+="<option value='"+result.list[i]['id']+"'>"+result.list[i]['caption']+"</option>";
                            }
                           
                        }
                    }
                    $("#c_album").html(html);
                });
            });
        }
    }
    return $.extend(true, md_list, app);
})($,md_list||{});
if(typeof md_user!=undefined){
    $(function(){
        md_user.init();
    });
}
